import React, { useEffect } from 'react'
import Router from './router'
import { useLocation, useNavigate } from 'react-router-dom'

const App = () => {
  const { pathname } = useLocation()
  const navigate = useNavigate()
  useEffect(() => {
    if(pathname !== '/login' && !localStorage.getItem('token')) {
      navigate('/login')
    }
  }, [pathname])
  return (
    <div>
      <Router></Router>
    </div>
  )
}

export default App